package com.eestimate.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang3.math.NumberUtils;

public class AppUtils {
	
	public static final String SYSTEM_USER = "system";
	
	public static String randomUuid() {
		String random = UUID.randomUUID().toString();
		return random.substring(0, 13);
	}
	
	public static boolean isValidUSPhoneNumber(String number) {
		
		if(NumberUtils.isDigits(number)) {
			if(number.length() == 10) {
				return true;
			}
		}
		
		return false;
		
	}
	
	public static boolean isPhoneValid(String phoneNumber) {
		String expression = "^\\(\\d{3}\\)\\d{3}-\\d{4}$";  
		CharSequence inputStr = phoneNumber;  
		Pattern pattern = Pattern.compile(expression);  
		Matcher matcher = pattern.matcher(inputStr);  
		if(matcher.matches()){  
			return true;
		}  
		
		return false;
	}
	
	@SafeVarargs
	public static <T> List<String> asListOfStrings(T... a) {
		
		if(a == null) {
			return null;
		}
		
		List<String> list = new ArrayList<String>(a.length);
		
		for (int i = 0; i < a.length; i++) {
			list.add(a[i].toString());
		}
		
        return list;
    }
	
}
